package com.example.getaudit.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.getaudit.entity.VToMsyBcd;
import com.example.getaudit.mapper.VToMsyBcdDao;
import com.example.getaudit.service.VToMsyBcdService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import lombok.RequiredArgsConstructor;

import java.util.List;

/**
 *  服务实现类
 *
 * @author 
 * @since 2025/03/18
 */
@Slf4j
@Service
@RequiredArgsConstructor
@DS("sqlserver")
public class VToMsyBcdServiceImpl implements VToMsyBcdService {

    private final VToMsyBcdDao vToMsyBcdDao;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Long create(VToMsyBcd vToMsyBcd ) {
        vToMsyBcdDao.insert(vToMsyBcd);
        return Long.valueOf(1);
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(VToMsyBcd vToMsyBcd) {
        vToMsyBcdDao.updateById(vToMsyBcd);
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(Long id) {
        vToMsyBcdDao.deleteById(id);
    }

    @Override
    public VToMsyBcd get(Long id) {
        return vToMsyBcdDao.selectById(id);
    }

    /**
     * 获取所有的商品条码
     *
     * @return
     */
    @Override
    public List<VToMsyBcd> getAll() {
        QueryWrapper<VToMsyBcd> vToMsyBcdQueryWrapper = new QueryWrapper<>();
        return vToMsyBcdDao.selectList(vToMsyBcdQueryWrapper);
    }


}
